<!--
 * @Description: 库存盘点审批
 * @Author: wangwangwang
 * @Date: 2020-11-18 15:34:16
 * @LastEditors: wangwangwang
 * @LastEditTime: 2021-09-02 09:46:47
-->
<template>
  <div class="flows-content">
    <el-container>
      <el-main style="margin-bottom: 20px; padding: 0;">
        <el-container direction="vertical">
          <FlowHeader :isReadOnly="readOnly" @saveSubmit="handleSubmit(1)" @sendSubmit="handleSubmit(2)" @handleBackEnd="handleSubmit(3)" @handleCC="handleSubmit(4)" @handleAssign="handleSubmit(5)" @handleBackUp="handleSubmit(6)" @handleAssist="handleSubmit(7)" @handleNode="handleSubmit(8)" @handleNodeImage="handleSubmit(9)" @handleCollection="handleSubmit(10)" />
          <el-main class="info">
            <div>
              <el-input v-model="title" class="flow-title" :disabled="$route.query.type*1!==1" placeholder="请输入流程标题"></el-input>
            </div>
            <div class="info-top">
              <div class="left">
                <span>单据号码：{{billCode}}</span>
                <span class="text">制单日期：{{billDate}}</span>
              </div>
              <div class="right">
                <span>发起人：{{applyPerson}}</span>
                <span class="text">状态：{{taskTypeText[taskStatus*1]}}</span>
              </div>
            </div>
            <div class="content">
              <div>
                <el-form ref="reffrom1" :inline="true" :model="data" label-width="140px">
                  <el-form-item prop="stationId">
                    <span slot="label">站点：</span>
                    <div style="width:290px;">{{data.station}}</div>
                  </el-form-item>
                  <el-form-item prop="updateTime">
                    <span slot="label">盘点时间：</span>
                    <div style="width:290px;">{{data.updateTime}}</div>
                  </el-form-item>
                  <el-form-item prop="warehouseId">
                    <span slot="label">盘点仓库：</span>
                    <div style="width:290px;">{{data.warehouse}}</div>
                  </el-form-item>
                  <el-form-item prop="rawId">
                    <span slot="label">盘点物料名称：</span>
                    <div style="width:290px;">{{data.raw}}</div>
                  </el-form-item>
                  <el-form-item prop="stock">
                    <span slot="label">盘点库存数量(吨)：</span>
                    <div style="width:290px;">{{data.stock}}</div>
                  </el-form-item>
                  <el-form-item prop="code">
                    <span slot="label">盘点人员：</span>
                    <div style="width:290px;">{{ data.userName }}</div>
                  </el-form-item>
                  <el-form-item prop="remark">
                    <span slot="label">备注：</span>
                    <div style="width: 660px">{{data.remark}}</div>
                  </el-form-item>
                </el-form>
              </div>
            </div>
            <div class="flows-details">
              <FlowContent ref="flowcontent" :title='title' :showSendVisible="showSendVisible" @handleCancel="handleCancel" @sendCode="sendCode" @handleFinish="handleFinish" @handleBusiness="handleBusiness" />
            </div>
          </el-main>
        </el-container>
      </el-main>
    </el-container>
  </div>
</template>
<script>
import FlowContent from '@/components/WorkFlow/flowContent';
import FlowHeader from '@/components/WorkFlow/flowHeader';
import { getUserInfo } from "@/utils/auth.js";
export default {
  components: {
    FlowContent,
    FlowHeader,
  },
  data() {
    return {
      type: 0,
      title: '库存盘点审批',
      billCode: '',
      billDate: '',
      applyPerson: '',
      taskTypeText: ['发起', '已保存', '审批中', '已完成', '撤销', '不通过'],
      taskStatus: 0,
      showSendVisible: false,
      readOnly: false,
      data: {
      }
    }
  },
  methods: {
    handleBusiness() {
      const params = {
        process_success: {
          url: '/icps/system/sign/basics/inventory/updateInventoryApproval',
          data: { ...this.data },
          httpMethod: 'post',
        },
        process_failure: ''
      }
      this.showSendVisible = false;
      this.$refs.flowcontent.handleToFlow(params);
    },
    /**
     * @Description: 
     * @Param: 1为保存，2为最后提交
     * @Author: wangwangwang
     * @param {*} type
     */
    handleFinish() {
    },
    handleSubmit(type) {
      const { query } = this.$route;
      if (query.type * 1 === 2 && type === 2 && query.taskType * 1 !== 2) { // 发起流程
        this.showSendVisible = true;
        return
      }
      const data = {
        dataSource: 'sign_stocksake1',
        dataContent: JSON.stringify(this.data)
      }
      this.$refs.flowcontent.saveFlows(type, data);
    },
    handleFlowChat() {
      this.$refs.flowcontent.showFlowNode()
    },
    handleCancel() {
      this.showSendVisible = false;
    },
    /**
     * @Description: 回显业务数据
     * @Param: 
     * @Author: wangwangwang
     */
    initFlowsData(data) {
      const { query } = this.$route;
      if (query.type * 1 !== 1) {
        this.title = query.taskName;
      }
      this.billCode = query.receiptNumber;
      this.billDate = query.createTime;
      this.data = data
    },
    sendCode(code) {
      this.billCode = code;
    },
  },
  created() {
    const { query } = this.$route;
    this.titlestatus = Number(query.type)
  },
  mounted() {
    const { query } = this.$route;
    if (query.type * 1 === 1) { // 发起流程
      this.initFlowsData(query);
      this.$refs.flowcontent.initBaseData('sign_stocksake1');
      this.billDate = new Date().Format('yyyy-MM-dd hh:mm:ss');
      this.applyPerson = getUserInfo().userRealName;
      return
    }
    this.initFlowsData(JSON.parse(query.dataContent));
    this.applyPerson = query.createUserName;
    this.taskStatus = query.taskStatus;
    if (query.isReadOnly*1===1) {
      this.readOnly = true;
    }
  }
}
</script>
<style lang="scss" scoped>
.content {
  @include discen;
  width: auto;
  > div {
    margin-top: 50px;
    width: 923px;
    border: 1px solid #e1e5ed;
    border-radius: 4px;
    padding: 20px;
  }
}
.flows-details {
  margin-top: 20px;
  justify-content: space-around;
}
.info {
  padding: 0 20px;
  background: #fff;
  .info-top {
    font-size: $font_size;
    color: #000000;
    @include discen_al;
    justify-content: space-between;
    height: 50px;
    border-top: 1px #e1e5ed solid;
    border-bottom: 1px #e1e5ed solid;
    .left {
      @include discen_al;
    }
    .text {
      margin-left: 60px;
    }
  }
}
</style>